// 1.2 Reverse a C-style String

#include <iostream>
using namespace std;

void reverse(char *str) {
	char *end = str; // point to the first element of str
	// cout<< *(++end) <<endl;	
	char tmp;
	if (str) {
		while (*end) {
			++end;
		}
		// cout <<"end is "<<end<<endl; // end is e
		--end; // \0
		// cout <<"end is "<<end<<endl; // end is e
		while (str < end) {
			tmp = *str;
			*str++ = *end;
			*end-- = tmp;
			// cout<<"Now->"<<*str<<endl;
		}
	}
}

void funcy(char *str) {
	char *start = str;
	for(; *str; str++);
	--str;

	while(start < str)
	{
	*str ^= *start;  //??
	*start ^= *str;
	*str-- ^= *start++;
	}
}

int main(){
	char a[6] = "abcde";
	reverse(a);
	// funcy(a);
	cout << a<<endl;
}